package com.chis.jmdatatimer.comm;

import com.chis.jm.bean.ChilInquireBean;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import redis.clients.jedis.ShardedJedis;

/**
 * @Description 根据儿童编码查询儿童询问诊表
 * @Company zwx
 * @author zww1
 * @version 2018/7/20
 */
public class RedisFindInquireTx implements TransactionJedis {
	/**日志*/
	private static Logger log = LogManager.getLogger(RedisFindInquireTx.class);
	/** 儿童编码 */
	private String childCode;
	/** 儿童询问诊表 */
	private List<ChilInquireBean> list;

	public RedisFindInquireTx(String childCode) {
		this.childCode = childCode;
	}

	@Override
	public void run(ShardedJedis jedis) throws Exception {

		try {
			jedis.select(13);
			byte[] bytes = jedis.get(childCode.getBytes());
			if (null != bytes && bytes.length > 0) {
				list = (List<ChilInquireBean>) JedisSerializeUtil.unserialize(bytes);
			}
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			throw new Exception(e.getMessage());
		}

	}

	public List<ChilInquireBean> getList() {
		return list;
	}
}
